from django.conf.urls.defaults import *
from mitems import views as mitems_views
from mitems import ajax as ajax_views
from django.conf import settings
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.conf.urls.static import static
from django.views.generic.simple import direct_to_template
#from persistent_messages.models import Message
#from social_auth.models import UserSocialAuth, Nonce, Association


# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
#admin.site.unregister(Message)
#admin.site.unregister(UserSocialAuth)
#admin.site.unregister(Nonce)
#admin.site.unregister(Association)

urlpatterns = patterns('',
    # Example:
#    (r'^minutes/', include('minutes.foo.urls')),
    url(r'', include('social_auth.urls')),
    url(r'', include('shorturls.urls')),
    (r'^messages/', include('persistent_messages.urls')),
    (r'^$', mitems_views.index),

    (r'^live/$', mitems_views.live),
    (r'^live/(?P<chapter>\w+)/$', mitems_views.live),
    url(r'^live/(?P<chapter>\w+)/(?P<category>\d+)/(?P<user_category>\d+)/(?P<country>\w+)/$', mitems_views.live, name='live_filter'),

    (r'^welcome/$', mitems_views.welcome),
    (r'^privacy/$', direct_to_template, {'template': 'privacy.html'}),
    (r'^terms/$', direct_to_template, {'template': 'terms-and-conditions.html'}),
    (r'^getting-started/$', direct_to_template, {'template': 'getting-started.html'}),
    (r'^signin-error/$', direct_to_template, {'template': 'signin-error.html'}),

    (r'^logout/$', mitems_views.logout_user),

    #ajax
    (r'^picture/upload/$', ajax_views.ajax_picture_upload),

    (r'^item/submit/$', mitems_views.item_upload),

    (r'^item/like/$', ajax_views.item_like),
    (r'^item/like/story/$', ajax_views.item_like, {'story': True}),

    (r'^item/delete/$', ajax_views.item_delete),
    (r'^item/delete/story/$', ajax_views.item_delete, {'story': True}),

    (r'^item/repost/$', ajax_views.item_repost),

    (r'^item/airtime/$', ajax_views.item_airtime),
    (r'^item/airtime/story/$', ajax_views.item_airtime, {'story': True}),

    (r'^item/facebook/post/$', ajax_views.item_facebook),
    (r'^item/facebook/post/story/$', ajax_views.item_facebook, {'story': True}),

    (r'^item/twitter/post/$', ajax_views.item_twitter),
    (r'^item/twitter/post/story/$', ajax_views.item_twitter, {'story': True}),

    (r'^item/question/$', ajax_views.item_question),

    (r'^items/update/$', ajax_views.items_update),

    url(r'^items/more/$', ajax_views.items_more),
    url(r'^items/more/(?P<chapter>\w+)/$', ajax_views.items_more, name='more_items'),
    url(r'^items/more/(?P<chapter>\w+)/(?P<category>\d+)/(?P<user_category>\d+)/(?P<country>\w+)/$', ajax_views.items_more, name='more_items_filter'),

    (r'^items/airtime/$', ajax_views.items_airtime),

    url(r'^items/filter/$', ajax_views.items_filter),
    url(r'^items/filter/(?P<chapter>\w+)/(?P<category>\d+)/(?P<user_category>\d+)/(?P<country>\w+)/$', ajax_views.items_filter, name='filter_items'),

    (r'^item/(?P<item_slug>[-\w]+)/$', mitems_views.item_view),
    url(r'^item/(?P<chapter>\w+)/(?P<item_slug>[-\w]+)/$', mitems_views.item_view, name="item_filter"),

    (r'^comment/submit/$', ajax_views.comment_upload),
    (r'^comment/submit/story/$', ajax_views.comment_upload, {'story': True}),

    (r'^comment/delete/$', ajax_views.comment_delete),
    (r'^comment/delete/story/$', ajax_views.comment_delete, {'story': True}),

    (r'^responses/(?P<item>\d+)/(?P<page>\d+)/$', ajax_views.responses_more),

    (r'^comment/like/$', ajax_views.comment_like),

    (r'^user/follow/$', ajax_views.user_follow),
    (r'^user/follow/story/$', ajax_views.user_follow, {'story': True}),

    (r'^user/unfollow/$', ajax_views.user_unfollow),
    (r'^user/unfollow/story/$', ajax_views.user_unfollow, {'story': True}),

    (r'^user/profile/follow/$', ajax_views.user_follow_profile),
    (r'^user/profile/right/follow/$', ajax_views.user_follow_profile, {'right': True}),

    (r'^user/profile/unfollow/$', ajax_views.user_unfollow_profile),
    (r'^user/profile/right/unfollow/$', ajax_views.user_unfollow_profile, {'right': True}),

    (r'^user/broadcaster/unfollow/$', ajax_views.user_unfollow_broadcaster),
    (r'^user/broadcaster/follow/$', ajax_views.user_follow_broadcaster),

    (r'^user/restore_airtime/$', ajax_views.user_restore_airtime),
    (r'^user/get_airtime/$', ajax_views.user_get_airtime),

    (r'^user/send_my_email/$', ajax_views.user_send_my_email),

    url(r'^user/(?P<username>[-.\w]+)/$', mitems_views.user_my_items, name='my_items_root'),

    url(r'^user/(?P<username>[-.\w]+)/(?P<page>\d+)/$', mitems_views.user_my_items, name='my_items'),

    url(r'^user/(?P<username>[-.\w]+)/followers/$', mitems_views.user_followers, name='user_followers'),
    url(r'^user/(?P<username>[-.\w]+)/followers/(?P<page>\d+)/$', mitems_views.user_followers, name='user_followers_page'),

    url(r'^user/(?P<username>[-.\w]+)/following/$', mitems_views.user_following, name='user_following'),
    url(r'^user/(?P<username>[-.\w]+)/following/(?P<page>\d+)/$', mitems_views.user_following, name='user_following_page'),

    url(r'^profile/$', mitems_views.user_profile, name='profile'),
    url(r'^notifications/$', mitems_views.user_notification, name='notifications'),
    #open popup for twitter box
    url(r'^share/open/(?P<provider>\w+)/(?P<id>\d+)/$', mitems_views.share_open, name='share_open'),

    url(r'^invite/facebook/$', ajax_views.invite_facebook, name='invite_facebook'),

    (r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '/static/images/favicon.ico'}),

    # Uncomment the admin/doc line below to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
#   (r'^admin/', include(admin.site.urls)),
    (r'^siteadminrealm/', include(admin.site.urls)),
#    url(r'^get_request_token/$', google.get_request_token),
#    url(r'^get_access_token/$', google.get_access_token),
    url(r'^google_contacts/$', mitems_views.google_contacts),
)

handler500 = "mitems.views.handler500"

if settings.DEBUG:
    urlpatterns += staticfiles_urlpatterns()
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
